package com.example.back.config;

import com.example.back.dao.records.PlayLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class SchedulingTaskConfig {

    @Autowired
    private PlayLogDao playLogDao;

    @Scheduled(cron = "0 30 2 * * ?")
    public void delTableLog() {
        long time = new Date().getTime();
        time = time - 5 * 24 * 60 * 60 * 1000;
        Date date = new Date(time);
        playLogDao.delFiveDaysTableLogs(date);

    }

    public static void main(String[] args) {
        long time = new Date().getTime();
        time = time - 5 * 24 * 60 * 60 * 1000;
        Date date = new Date(time);
        System.out.println(date);
    }
}
